package com.exam.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.entity.ExamManage;
import com.exam.vo.CollectVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CollectionMapper {

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into collection(examCode,studentId,collectDate,source)" +
            " values(#{examCode},#{studentId},#{collectDate},#{source})")
    int add(CollectVO collectVO);

    //根据学生id和试卷id查询收藏的考试
    @Select("select * from collection where examCode = #{examCode} and studentId = #{studentId}")
    CollectVO findByExcodeAndStudentId(Integer examCode,Integer studentId);

    @Delete("delete from collection where examCode = #{examCode} and studentId = #{studentId}")
    int delete(CollectVO collectVO);

    @Select("select * from collection where studentId = #{studentId}")
    IPage<CollectVO> findAll(Page page, @Param("studentId") Integer studentId);

}
